package config

import (
	"flag"
	"fmt"
	"github.com/spf13/viper"
	"os"
)
type SrvContext struct{
	Mode string
}
var SrvCtx SrvContext


var Cfg *viper.Viper

func init() {
	defer func() {
		if e := recover(); e != nil {
			fmt.Println(e)
			os.Exit(-1)
		}
	}()
	var e error

	flag.StringVar(&SrvCtx.Mode, "mode", "local", "go run main.go -mode pro")
	flag.Parse()


	Cfg = viper.New()

	Cfg.SetConfigFile("G:/go_workspace/GOPATH/src/helloworld/config/local.yaml")
	if e = Cfg.ReadInConfig(); e != nil {
		panic(e)
	}
	fmt.Println(Cfg.GetString("version"))
}